<?php
/*
Plugin Name: BH Tags
Plugin URI: http://blackhacker.net/projects/bh-tags/
Description: My adaption of Stephanie Booth's Bunny Tags
Version: 0.1
Author: BH
Author URI:

  Copyright 2005  Blackhacker (email : bh@blackhacker.net)

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

INSTRUCTIONS
============

Add the following code to your template where you want your tags to appear:

<?php the_bunny_tags(); ?>

The keywords will appear as links wrapped in <p class="tags">Tags: ...</p>. You may want to add CSS to style the list.

If you want other html, you can try things like the following (thanks, Scott):

<?php the_bunny_tags("<ul><li>", "</li></ul>", "</li><li>"); ?>

If you want keywords to be translated as tags for posts which do not have tags defined, change the setting below. Attention! your keyword list must be stored in a custom field 'keywords' and be a comma-separated list -- otherwise you will need to edit the



 function get_bunny_tags_list().

WARNING: if your pages aren't utf-8 and you use non-ascii characters in your tags, your tags might not get indexed properly.

*/


/*
CHANGELOG
=========
0.1  - Initial release 03.30.2006

CREDITS
=======

*/

require_once('BH_Tags.php');
include_once('BH_Tag_Cloud_Widget.php');
include_once('BH_Related_Tags_Widget.php');


// use these function to output as tags the space-separated content of the meta field "tags"; depending on your setting of $strict at the beginning of this file, the function may treat as tags the comma-separated content of the meta field "keywords" if "tags" doesn't exist. You may pass arguments $before, $after, and $separator to control the formatting.


if(!function_exists('bh_post_tags')) {
	function bh_post_tags($before = '<p class="tags">Tags: ', $between = ', ', $after = '</p>') {
		print(BH_Tags::get_post_tag_links($before, $between, $after, get_bloginfo('url') .'/tag/'));
	}
}

if (!function_exists('bh_post_technorati_tags')) {
	function bh_post_technorati_tags($before = '<p class="tags">Tags: ', $between = ', ', $after = '</p>') {
        	print(BH_Tags::get_post_tag_links($before, $between, $after, 'http://technorati.com/tags/'));
	}
}

if (!function_exists('bh_post_del_icio_us_tags')) {
	function bh_post_del_icio_us_tags($before = '<p class="tags">Tags: ', $between = ', ', $after = '</p>') {
        	print(BH_Tags::get_post_tag_links($before, $between, $after, 'http://del.icio.us/tags/'));
	}
}

if (!function_exists('bh_related_tags')) {
	function bh_related_tags($tag, $before = '<p class="tags">Tags: ', $between = ', ', $after = '</p>') {
		print(BH_Tags::get_related_tag_links($before, $between, $after, get_bloginfo('url') .'/tag/', $tag));
	}
}

if (!function_exists('is_tag')) {
	function is_tag($tag = '') {
		$tag_var = urlencode(urldecode(get_query_var("tag")));
		if (!$tag_var) return false;

		if ($tag) return $tag == $tag_var;

		return true;
	}
}

if(!function_exists('bh_the_tag')) {
	function bh_the_tag() {
		if (is_tag()) {
			echo get_query_var("tag");
		}
	}
}

add_action('simple_edit_form', array('BH_Tags','simple_edit_form'));
add_action('edit_form_advanced', array('BH_Tags','simple_edit_form'));
add_action('edit_page_form', array('BH_Tags','simple_edit_form'));
add_action('edit_post', array('BH_Tags','edit_post'));
add_action('publish_post', array('BH_Tags', 'edit_post'));
add_action('save_post', array('BH_Tags', 'edit_post'));
add_filter('rewrite_rules_array',array('BH_Tags','rewrite_rules'));
add_filter('query_vars',array('BH_Tags','query_vars'));
add_action('parse_query',array('BH_Tags','parse_query'));
add_filter('the_content', array('BH_Tags', 'the_content'));
add_filter('the_excerpt_rss', array('BH_Tags', 'the_content'));

?>
